package com.huang.controller;

import com.huang.pojo.*;
import com.huang.service.AdminService;
import com.huang.service.StudentService;
import com.huang.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
public class TimelineController {
    @Autowired
    @Qualifier("AdminServiceImpl")
    private AdminService adminService;
    @Autowired
    @Qualifier("TeacherServiceImpl")
    private TeacherService teacherService;
    @Autowired
    @Qualifier("StudentServiceImpl")
    private StudentService studentService;

    @RequestMapping("/timeline/allNotice")
    public String allNotice(Model model){

        List<Announcement> list = adminService.historyNotice();
        model.addAttribute("list", list);
        return "NoticeTimeline";
    }

    @RequestMapping("/timeline/allActivity")
    public String allActivity(Model model){

        List<Activity> list=adminService.showAllActivity();
        model.addAttribute("list",list);

        Date now = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格式
        String time = dateFormat.format(now);
        model.addAttribute("nowTime",time);
        return "ActivityTimeline";
    }

    @RequestMapping("timeline/studentScore")
    public String studentScore(Student student,Model model){
        List<StudentScore> list=studentService.showSelfScore(student);
        model.addAttribute("list",list);
        model.addAttribute("studentNo",student.getStudentNo());
        return "ScoreTimeline";
    }

    @RequestMapping("/user/toViewDiaryDetail")
    public String toViewDiaryDetail(UserDiary userDiary,Model model){

        List<UserDiary> list=studentService.viewUserDiaryDetail(userDiary);
        model.addAttribute("list",list);

        return "UserDiaryDetail";
    }


}